home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / PNOUTREF.C < prev    next >
Text File  |  1992-11-21  |  5KB  |  124 lines

  1. #ifndef NO_MEMORY_H
  2. #include <memory.h>
  3. #endif
  4. #define        CURSES_LIBRARY  1
  5. #include <curses.h>
  6. #undef pnoutrefresh
  7.  
  8. #ifndef        NDEBUG
  9. char *rcsid_pnoutref = "$Header: c:/curses/portable/RCS/pnoutref.c%v 2.0 1992/11/15 03:29:14 MH Rel $";
  10. #endif
  11.  
  12.  
  13.  
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   pnoutrefresh()       - refresh pad without updating physical screen
  18.  
  19.   X/Open Description:
  20.        The prefresh routine copies the specified pad to the physical
  21.        terminal screen.  It takes account of what is already
  22.        displayed on the screen to optimize cursor movement.
  23.  
  24.        The pnoutrefresh routine copies the named pad to the virtual
  25.        screen. It then compares the virtual screen with the physical
  26.        screen and performs the actual update.
  27.  
  28.        These routines are analogous to the routines wrefresh and
  29.        wnoutrefresh except that pads, instead of windows, are
  30.        involved.  Additional parameters are also needed to indicate
  31.        what part of the pad and screen are involved. The upper left
  32.        corner of the part of the pad to be displayed is specified by
  33.        py and px.  The coordinates sy1, sx1, sy2, and sx2 specify the
  34.        edges of the screen rectangle that will contain the selected
  35.        part of the pad.
  36.  
  37.        The lower right corner of the pad rectangle to be displayed is
  38.        calculated from the screen co-ordinates.  This ensures that
  39.        the screen rectangle and the pad rectangle are the same size.
  40.  
  41.        Both rectangles must be entirely contained within their
  42.        respective structures.
  43.  
  44.   PDCurses Description:
  45.        Contrary to the statements above, the pnoutrefresh() routine
  46.        will not perform an update to the physical screen.  This task
  47.        is performed by doupdate().
  48.  
  49.   X/Open Return Value:
  50.        The prefresh() function returns OK on success and ERR on error.
  51.  
  52.   PDCurses Errors:
  53.        It is an error to pass a null WINDOW* pointer.
  54.  
  55.   Portability:
  56.        PDCurses        int pnoutrefresh( WINDOW* w, int py, int px,
  57.                                                int sy1, int sx1,
  58.                                                int sy2, int sx2 );
  59.        X/Open Dec '88  int pnoutrefresh( WINDOW* win, int py, int px,
  60.                                                int sy1, int sx1,
  61.                                                int sy2, int sx2 );
  62.        BSD Curses      int pnoutrefresh( WINDOW* w, int pminrow, int pmincol,
  63.                                                int sminrow, int smincol,
  64.                                                int smaxrow, int smaxcol );
  65.        SYS V Curses    int pnoutrefresh( WINDOW* win, int py, int px,
  66.                                                int sy1, int sx1,
  67.                                                int sy2, int sx2 );
  68.  
  69. **man-end**********************************************************************/
  70.  
  71. int    pnoutrefresh(WINDOW* w,int py,int px,int sy1,int sx1,int sy2,int sx2)
  72. {
  73. register chtype*       dstp;
  74. register chtype*       srcp;
  75.        WINDOW*         s = tmpwin;
  76.        int             sline = sy1;
  77.        int             pline = py;
  78.  
  79.  
  80.        if (w == (WINDOW *)NULL)
  81.                return( ERR );
  82.  
  83.        while (sline <= sy2)
  84.        {
  85.                if (pline < w->_maxy)
  86.                {
  87. #if    defined(DOS) || defined(OS2)
  88. #  if  SMALL || MEDIUM
  89.                        srcp = &(w->_y[pline][px]);
  90.                        dstp = &(s->_y[sline][sx1]);
  91.                        movedata(FP_SEG(srcp), FP_OFF(srcp),
  92.                                 FP_SEG(dstp), FP_OFF(dstp),
  93.                                 (sx2 - sx1 + 1) * sizeof(chtype));
  94. #  else
  95.                        memcpy(&(s->_y[sline][sx1]),
  96.                               &(w->_y[pline][px]),
  97.                               (sx2 - sx1 + 1) * sizeof(chtype));
  98. #  endif
  99. #endif
  100.  
  101.                        if ((s->_firstch[sline] == _NO_CHANGE) ||
  102.                            (s->_firstch[sline] > sx1))
  103.                        {
  104.                                s->_firstch[sline] = sx1;
  105.                        }
  106.  
  107.                        if (sx2 > s->_lastch[sline])
  108.                                s->_lastch[sline] = sx2;
  109.  
  110.                        w->_firstch[pline] = _NO_CHANGE;  /* updated now */
  111.                        w->_lastch[pline] = _NO_CHANGE;  /* updated now */
  112.                }
  113.                sline++;
  114.                pline++;
  115.        }
  116.  
  117.        if (w->_clear)
  118.        {
  119.                w->_clear = FALSE;
  120.                s->_clear = TRUE;
  121.        }
  122.        return( OK );
  123. }
  124.